import axios from "axios";

axios.defaults.baseURL = "/";
axios.defaults.timeout = 60000;

axios.interceptors.request.use((req) => {
    let url = req.url;
    let prefix = "";
    if (import.meta.env.MODE == "production") {
        if (url?.includes("get_wechat_signature")) {
            prefix = "";
        } else {
            prefix = "https://www.nbd.com.cn";
        }
    }

    req.url = prefix + url;

    return req;
});

axios.interceptors.response.use(
    (res) => {
        return res;
    },
    (err) => {
        return Promise.reject(err);
    },
);

export default axios;
